package com.dayatang.android.Task;

import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;

import com.dayatang.android.Activity.R;
import com.dayatang.android.Util.HttpUtil;

public class ProjectSearchTask extends AsyncTask<String, Integer, String> {

	private ProgressDialog pd;
	private Context context;
	
	public ProjectSearchTask(Context context) {
		this.context = context;
		pd = ProgressDialog.show(context, "", context.getString(R.string.loading), true, true);
	}

	protected String doInBackground(String... params) {
		String url = null;
		if (params[2].equals("byname")) {
			url = params[0] + "/remote/project-search.action?projName=" + params[1] + "&username=" + params[3];
		} else if(params[2].equals("byid")) {
			url = params[0] + "/remote/project-search.action?projectid=" + params[1] + "&username=" + params[3];
		}
		return HttpUtil.httpclient(url,context);
	}

	protected void onCancelled() {
		super.onCancelled();
	}

	protected void onPostExecute(String result) {
		pd.dismiss();
	}

}
